package com.chlitina.store.common.utils;

import com.chlitina.store.modules.base.entity.StoreProduct;

public class StoreProductUtils {
	public static String getName(StoreProduct product) {
		if (product.getProduct_type() == StoreProduct.TYPE_SELF) {
			return product.getStoreSelfProduct().getName();
		} else {
			return product.getProduct().getName();
		}
	}
	
	public static String getSpec(StoreProduct product) {
		if (product.getProduct_type() == StoreProduct.TYPE_SELF) {
			return product.getStoreSelfProduct().getSpec();
		} else {
			return product.getProduct().getSpec();
		}
	}
	
	public static String getImage(StoreProduct product) {
		if (product.getProduct_type() == StoreProduct.TYPE_SELF) {
			return product.getStoreSelfProduct().getImage();
		} else {
			return product.getProduct().getImage();
		}
	}
	
	public static float getRetailPrice(StoreProduct product) {
		if (product.getProduct_type() == StoreProduct.TYPE_SELF) {
			return product.getStoreSelfProduct().getRetail_price();
		} else {
			return product.getProduct().getRetail_price();
		}
	}
	
	public static String getCategory(StoreProduct product) {
		if (product.getProduct_type() == StoreProduct.TYPE_SELF) {
			return product.getStoreSelfProduct().getStoreSelfProductCategory().getName();
		} else {
			if(product.getProduct()!=null){
				return product.getProduct().getProductCategory().getName();
			}
		}
		return "";
	}
	
}
